#include "TGraph.h"
#include "stdio.h"
#include "memory.h"
void TGraph::readFromFile(const char* file)
{
	
	FILE* f = fopen(file,"r");
	fscanf(f,"%i\n", &n);

	init(n);
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
			fscanf(f,"%i ", adjacencyMatrix+i*n+j);
		fscanf(f,"\n");
	}
	fclose(f);
}

void TGraph::destroy()
{
	delete[] adjacencyMatrix;
	adjacencyMatrix=NULL;
}

void TGraph::init( int _n )
{
	destroy();
	n=_n;
	adjacencyMatrix = new int[n*n*sizeof(int)];
}

void TGraph::fillAdjMatrix( int * d )
{
	memcpy(d,adjacencyMatrix,n*n*sizeof(int));
}
